package com.kaili.tms.controller.web.v1;

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.tms.pojo.dto.CostStatisticsQueryDTO;
import com.kaili.tms.pojo.entity.costStatisticsEntity;
import com.kaili.tms.pojo.vo.CostStatisticsDetailVO;
import com.kaili.tms.pojo.vo.CostStatisticsVO;
import com.kaili.tms.service.ExpenseAccountService;
import com.kaili.tms.version.ApiVersion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

/**
 * @Desc: 成本统计
 * @author: zengshuai
 * @Time: 19-2-12 下午2:36
 * @Copyright: © 2018 杭州凯立通信有限公司 版权所有
 * @Warning: 本内容仅限于公司内部传阅, 禁止外泄或用于其它商业目的
 */
@ApiVersion(1)
@RequestMapping("/{api_version}")
@RestController
@Validated
@Api(tags = "成本统计", description = "成本统计相关API")
public class CostStatisticsController {

    @Autowired
    private ExpenseAccountService expenseAccountService;


    @GetMapping("/costStatistics")
    @ApiOperation(value = "成本统计6个月汇总信息")
    public Map<String,List<costStatisticsEntity>> querySixMonthCostStatistics(@ModelAttribute CostStatisticsQueryDTO dto){
        return expenseAccountService.querySixMonthCostStatistics(dto);
    }

    @GetMapping("/costStatisticsDetail")
    @ApiOperation(value = "分页查询成本统计明细信息")
    public Page<CostStatisticsDetailVO> queryCostStatisticsDetail(@ModelAttribute CostStatisticsQueryDTO dto){
        Page<CostStatisticsDetailVO> pager = new Page<>(dto.getPage(),dto.getPageSize());
        return expenseAccountService.queryCostStatisticsDetail(pager, dto);
    }

    @GetMapping("/DetailMoney")
    @ApiOperation(value = "统计明细信息总金额")
    public Double queryDetailTotalMoney(@ModelAttribute CostStatisticsQueryDTO dto){
        return expenseAccountService.queryDetailTotalMoney(dto);
    }

}
